|
Referential transparency and referential opacity are properties of parts of computer programs. An expression is said to be referentially transparent if it can be replaced with its value without changing the behavior of a program (in other words, yielding a program that has the same effects and output on the same input). The opposite term is referential opacity. While in mathematics all function applications are referentially transparent, in programming this is not always the case. The importance of referential transparency is that it allows the programmer and the compiler to reason about program behavior as a rewrite system. This can help in proving correctness, simplifying an algorithm, assisting in modifying code without breaking it, or optimizing code by means of memoization, common subexpression elimination, lazy evaluation, or parallelization. Referential transparency is one of the principles of functional programming; only referentially transparent functions can be memoized (transformed into equivalent functions which cache results). Some programming languages provide means to guarantee referential transparency. Some functional programming languages enforce referential transparency for all functions. As referential transparency requires the same results for a given set of inputs at any point in time, a referentially transparent expression is therefore deterministic. == History == The concept (although not the term) seems to have originated in Alfred North Whitehead and Bertrand Russel's ''Principia Mathematica'' (1910–13). It was adopted in analytical philosophy by Willard Van Orman Quine in ''Word and Object'' (1960):
The term appeared in its contemporary usage, in the discussion of variables in programming languages, in Christopher Strachey's seminal set of lecture notes ''Fundamental Concepts in Programming Languages'' (1967). The lecture notes referenced Quine's ''Word and Object'' in the bibliography. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Referential transparency」の詳細全文を読む スポンサード リンク
|